package cn.source.zk.service.impl;

import cn.source.zk.domain.entity.DevModel;
import cn.source.zk.mapper.ZkDevModelMapper;
import cn.source.zk.service.IZkDevModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ZkDevModelServiceImpl implements IZkDevModelService {

    @Autowired
    private ZkDevModelMapper devModelMapper;

    /**
     * 查询分页列表
     * @param devModel
     * @return
     */
    public List<DevModel> list(DevModel devModel) {
        return devModelMapper.selectPageList(devModel);
    }

    /**
     * 检查代码是否存在
     * @return
     */
    public boolean checkCodeExist(String code,Long num) {

        int result = devModelMapper.countByCode(code,num);

        return result > 0;
    }

    /**
     * 新增设备类型
     * @param devModel
     * @return
     */
    public int add(DevModel devModel) {
        return devModelMapper.insert(devModel);
    }

    /**
     * 根据id查询设备类型信息
     * @param num
     * @return
     */
    public DevModel getById(Long num) {
        return devModelMapper.selectById(num);
    }

    /**
     * 修改设备类型
     * @param devModel
     * @return
     */
    public int edit(DevModel devModel) {
        return devModelMapper.update(devModel);
    }

    /**
     * 删除设备类型
     * @param nums
     * @return
     */
    public int del(List<Long> nums) {
        return devModelMapper.delete(nums);
    }
}
